﻿var pageIndex = 1;
$(function () {
    getList(1);
    $("#addBtn").click(function () {
        var name = $("#name").val();
        add(name); 
    });
});

function getList(page) {
    pageIndex = page;
    var keyword = $("#keyword").val();
    var str = objectJS.getKeywordList(pageIndex, 10, keyword);
    var list = JSON.parse(str);
    var html = template("tplList", { data: list.Data });
    $("#list").html(html);
}

function del(id) {
    layer.confirm('是否确定删除采集新闻的关键词？', {
        title: '系统提示',
        btn: ['删除', '取消'] //按钮
    }, function () {
        unifyResult({
            func: "delKeyword",
            success: function (res) {
                getList(pageIndex);
            }
        }, id);
    }, function () {

    });
}


function add(name) {
    unifyResult({
        func: "addKeyword",
        success: function (res) {
            getList(pageIndex);
        }
    }, name);
}